define(function(require,exports,module){
	
	
	$("#carStatus").val($('.carStatusVal').val());
    $("#houseStatus").val($('.houseStatusVal').val());
	
	
	//加载城市选择插件
	
	require.async('jquery-citySelect/jquery.cityselect',function(){
		var prov = $(".province").val();
		var city =$(".cityOpt").val();
		$("#city").citySelect({
			url:"../../../themes/theme_default/media/js/jquery-citySelect/city.json",
			prov:prov, //省份 
		    city:city, //城市 
		    required:true,
		    nodata:"none" //当子集无数据时，隐藏select 
		});
	})
	
	//表单验证
	require.async('/plugins/jquery-validation-1.13.0/jquery.validate.min',function(){
		require.async('/plugins/jquery-validation-1.13.0/additional-methods',function(){
			$("#detailForm").validate({
				rules:{
					birthday:{
						required:true
					}
				},
				messages:{
					birthday:{
						required:"请填写你的生日"
					}
				},
				errorPlacement:function(error, element){
				  	element.parents(".ipt").find("em").html(error);	
				},
				success:function(element){
					element.parents(".ipt").find("em").html("");
				},
			    success:function(label){
			    },
				submitHandler:function(form){
					require.async(['/plugins/layer-v1.8.4/skin/layer.css','/plugins/layer-v1.8.4/layer.min'],function(){
					require.async('jquery.form',function(){
						$("form").ajaxSubmit({
							   dataType:'json',
							   success:function(data){
								   if(data.result==true){
									   $.layer({
		    								type: 1,
		    							    closeBtn: [0,true],
		    				                title: "&nbsp;",
		    							    area: ['384px', '186px'],
		    							    border: [1, 1, '#cecfd0'],
		    							    time:3,
		    							    page: {
		    							        html: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>'+data.msg+'</span></div><div class="tipsMsg"><i class="tipsTime">3</i>秒后窗口自动关闭</div></div>'
		    							    },
		    							    close: function(index){
		    							    	window.location.reload();
		    							    },
		    							    end: function(){
		    							    	window.location.reload();
		    							    },
		    							    success:function(){
		    					                var time = 3;
		    					                function tipsTime(){
		    					                 time--;
		    					                 $(".tipsTime").html(time)
		    					                 if(time == 0)
		    					                 {
		    					                  clearInterval(timeCount)
		    					                 }
		    					                }
		    					                var timeCount = setInterval(function(){tipsTime()},1000);
		    					               }
		    							});
			    					}else{
			    						$.layer({
											type: 1,
										    closeBtn: [0,true],
							                title: "&nbsp;",
										    area: ['384px', '186px'],
										    border: [1, 1, '#cecfd0'],
										    time:3,
										    page: {
										        html: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+data.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn">确定</a></div></div>'
										    },
										    close: function(index){
										    	window.location.reload();
										    },
										    end: function(){
										    	window.location.reload();
										    }
										});
										$(".okBtn").click(function(){
											window.location.reload();
										});
			    					}
							   }
						   })
					})
	    			});					
				}
			})
		})
	})
	
});